package com.huawei.appmarket.support.audio;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.GlideException;
import com.huawei.appmarket.framework.widget.uxwidget.roundedimageview.RoundedImageView;
import java.lang.ref.WeakReference;
import o.dgm;
import o.dky.c;
import o.Logger;
import o.epg;
import o.rz;
import o.zn;
import o.zz;

public class AudioPlayFloatButton extends RelativeLayout {
    private epg ˊ;
    private AudioBean ˋ;
    private RoundedImageView ˎ;
    private AudioFrequencyView ॱ;

    static class a implements zn<Bitmap> {
        private WeakReference<AudioPlayFloatButton> ˋ;

        public a(AudioPlayFloatButton audioPlayFloatButton) {
            this.ˋ = new WeakReference(audioPlayFloatButton);
        }

        public boolean ॱ(@Nullable GlideException glideException, Object obj, zz<Bitmap> zzVar, boolean z) {
            AudioPlayFloatButton audioPlayFloatButton = (AudioPlayFloatButton) this.ˋ.get();
            if (!(audioPlayFloatButton == null || audioPlayFloatButton.ˎ == null)) {
                Context context = audioPlayFloatButton.getContext();
                if (context instanceof Activity) {
                    int ˊ = dgm.ˊ(dgm.ˎ((Activity) context));
                    audioPlayFloatButton.ˎ.setScaleType(ScaleType.CENTER);
                    audioPlayFloatButton.ˎ.setImageResource(ˊ);
                }
            }
            if (Logger.ˎ()) {
                Logger.ˏ("AudioPlayFloatButton", "load icon fail");
            }
            return true;
        }

        public boolean ˎ(Bitmap bitmap, Object obj, zz<Bitmap> zzVar, rz rzVar, boolean z) {
            return false;
        }
    }

    public AudioPlayFloatButton(Context context) {
        this(context, null);
    }

    public AudioPlayFloatButton(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public AudioPlayFloatButton(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˊ(context);
    }

    private void ˊ(Context context) {
        int dimensionPixelSize = context.getResources().getDimensionPixelSize(c.ˎ);
        LayoutParams layoutParams = new RelativeLayout.LayoutParams(dimensionPixelSize, dimensionPixelSize);
        layoutParams.addRule(13);
        this.ˎ = new RoundedImageView(context);
        this.ˎ.setOval(true);
        this.ˎ.setScaleType(ScaleType.CENTER_CROP);
        addView(this.ˎ, layoutParams);
        this.ॱ = new AudioFrequencyView(context);
        addView(this.ॱ, layoutParams);
        this.ॱ.ˋ();
        this.ˊ = new epg(context);
        setBackground(this.ˊ);
    }

    public AudioBean ˎ() {
        return this.ˋ;
    }

    public void setData(AudioBean audioBean) {
        this.ˋ = audioBean;
        ॱ();
    }

    private void ॱ() {
        String ˎ;
        int ʼ;
        int i = 0;
        String str = "";
        if (this.ˋ != null) {
            ˎ = this.ˋ.ˎ();
            ʼ = this.ˋ.ʼ();
            i = this.ˋ.ᐝ();
        } else {
            ˎ = str;
            ʼ = 0;
        }
        this.ˎ.setScaleType(ScaleType.CENTER_CROP);
        Glide.ˏ(getContext().getApplicationContext()).ॱ().ˎ(ˎ).ॱ(new a(this)).ˏ(this.ˎ);
        this.ˊ.ˎ(i);
        this.ˊ.ˋ(ʼ);
    }

    public void ˊ() {
        this.ॱ.ˋ();
    }

    public void ˏ() {
        this.ॱ.ˎ();
    }

    public void ˋ() {
        if (this.ˋ != null) {
            this.ˊ.ˋ(this.ˋ.ʼ());
        }
    }
}
